import pika

# Connection parameters
credentials = pika.PlainCredentials('XuYixuan', 'Xyx20040422')
connection = pika.BlockingConnection(pika.ConnectionParameters('82.156.163.134', 5672, '/', credentials))
channel = connection.channel()

# Declare a queue
channel.queue_declare(queue='user_actions')

# Send messages
for i in range(10):
    message = f'用户{i}点击了商品{i}'
    channel.basic_publish(exchange='',
                          routing_key='user_actions',
                          body=message.encode('utf-8'))
    print(f" [x] Sent '{message}'")

# Close the connection
connection.close()